package unclassified.simple;

public class CheckWhetherTwoStringsAreAlmostEquivalent_5910 {
    public boolean checkAlmostEquivalent(String word1, String word2) {
        int[] w1 = new int[26];
        int[] w2 = new int[26];
        for (int i = 0; i < word1.length(); i++) {
            w1[word1.charAt(i) - 'a']++;
            w2[word2.charAt(i) - 'a']++;
        }
        for (int i = 0; i < 26; i++) {
            if (Math.abs(w1[i] - w2[i]) > 3) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        CheckWhetherTwoStringsAreAlmostEquivalent_5910 cwt = new CheckWhetherTwoStringsAreAlmostEquivalent_5910();
        System.out.println(cwt.checkAlmostEquivalent("zzzyyy", "iiiiii"));

    }
}
